import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = `MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAsmw8hsudwzqX39/fu/eW
2S2O0H9Ey2HO8/e4rIEgNPYOhICC7YoAcOS9bxlq8xrKiBhKjio6K4835gy2YGd8
zEXU1++ayLPISt1D6UxpRzoD5M16TXvOmNI3niV0qQZe91mhNQGykqfaYBqxiRdx
cTrDcXS2ZHMYlIA6xayUdubOvrZ8nvi3NpDZLvsefQVbdv+VFA/FrjKQBnlb5XP/
VPT/2IstA72DSd3iLlenpuvSqN1pFH5tq/F1+Z2ALuU0cjEzqWn8eU7KJr9WS5FB
tpyUkpGHAcSJr74F2nvhhzDNZBezonqns6095/7qkXInJKGQOxGQRPax2tNw7s9T
jQkSXMLOYkRGJU9hXGg506H7Uh06+rAwCwc307h90jS1Klpwbl1/1ib7pK3M17aV
KoFxPDbSjVD8METTsaTeOBjxWlxuTjtzekseay8L/7OYGCrdbyMwBELDodSTbiei
TuAWZ9T96SsqJ3q4hkc3DIquk9oLdb+vjg4r9N3g8Is/AgMBAAE=`

const privateKey = `MIIHTjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIOIjUnKdRIQYCAggA
MBQGCCqGSIb3DQMHBAgzO59XI6YUHwSCBwh1QJepwFrDVBN/72LlIeCULeSXal/B
yqqgLTUdxBDo+P8Fb5kLf+tXZ0SiUlK0Y1+IGt8DLEtGdifJOQUBZEViJv80kxaa
eAeQYSXEfFmTWYuVrNT0LJnCUu7YNxEnoYVtny4EkpcBM9/5N6RBceEFMHg22IBU
HCqLXquH3i6w0BzImsohxSsRKWLkHAkLnv+tqWLrE8rjOVwk2EULzXvX2fWNWpIU
fBA7GWxfnb4LUPaRvJsNjSxSD8Og+TndmWWCB2dqQtQR4fdVdriYobbi4VecqYj1
vKuVL99LxKtRvnSdyaKFsU2lCsqVnoJqVk/c8TIa5Wg6zHpEaVCphcWB3O/JUVpm
I8Zov8wOJ001V+fvQ8MM9c+5iVntox9LtoWIKFIQQ23W+qLH3n6c66cBL921CDi/
fQjJ49FAZA32K/dcDNby53u+jYDSsB/fBL2PywwrMtr2b7eELIlv8SOGD5EsCUKj
1A/jV/ajpRJJMvXzLjzidtVioTDPCGofFv2Yi3ljZAw5yzaiK9v9S8H1zLVPTWEL
XefryxC52jgf+fQfVH7W95C3TmOUhY3U0lLrzsaHnBuF+diHktnmaWL6zzofZuHD
pcjc9rE1dq3R2WWXkMcUv9SFXr7Hqdd9wbEONoI+1z+HkC9xjpXnX7SY8AWNsWIU
VthwfvEBeFuEzDZKdPOG0WpspVSRIukkLOGRdgiSM7s8IrfHK5wQ3RKT5nOld0Ll
1U1Hn7pd/+5q0/zU3FVBbn3E4/cgZB1yTGgrL+IQwQEAW1horlFyRTdjFqnDzhPt
8PTiy2DvoxQyG8uXytgjMeOsJ3x+IABqr1pVd3KlNYegtC9TwAgn8oCONp/GDxD7
rlyiWxIYuC20OvFPi5VTM6U+rtXndQDqmu/HpM94PUGvQKQFEqHfWGZjC7iV37LO
jo/KLMXX8+Q/o1WEy5i6s4rItAvo5S5rN+pZvxpQmHKo5QUuC8Ev+/mYtKlFIB3E
+AFFZ/sY2s4cyOSzytfVz2rxmTX13Vefp3BqoXAQuQbrqZkjAkC84m5BhcHsmErx
cOC8ZTnQeN6wYL8/5x1WjntmMt7LjpC758LzAQP82TE4fDYweJ5gVErhiE2qhmye
uNnOxHXMrJxZBQEaV95MoGnIGvCD5vvjkz2+dMzBxMkiW865iy7b3Grwt8CPb0C4
4+Ujcfk27yygK`

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

